add sliding window support for webgpu gqa#25372
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds support for a sliding window mask in the GPU-based group query attention (GQA) softmax shader, allowing attention to be constrained to a local window of past tokens.
- Propagate a new
local_window_sizeparameter through ComputeInternal, ApplyAttention, and ComputeInPlaceSoftmax. - Extend
InPlaceSoftmaxProgramto acceptlocal_window_sizeand emit conditional shader code for sliding-window masking. - Update function signatures and uniform variable setup to include the new window size parameter.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| contrib_ops/webgpu/bert/group_query_attention.cc | Added local_window_size_ guard for FlashAttention and pass it to ApplyAttention. |
| contrib_ops/webgpu/bert/attention_common.h | Extended ApplyAttention signature to accept local_window_size. |
| contrib_ops/webgpu/bert/attention.h | Updated InPlaceSoftmaxProgram constructor and added local_window_size_ field. |
| contrib_ops/webgpu/bert/attention.cc | Injected sliding-window logic into shader code and passed local_window_size through to the program. |
Comments suppressed due to low confidence (2)
onnxruntime/contrib_ops/webgpu/bert/attention.cc:228
- [nitpick] Consider adding unit or integration tests to cover the new sliding window behavior in InPlaceSoftmaxProgram to ensure correctness under various window sizes, including edge cases like window size zero or larger than sequence length.
bool has_sliding_window = local_window_size_ != -1;
onnxruntime/contrib_ops/webgpu/bert/group_query_attention.cc:199
- [nitpick] Align the indentation for this condition with the other conditions in the if statement to improve readability (e.g., match the two-space indent used for
head_sink == nullptr).
local_window_size_ == -1 &&
fs-eire
reviewed
Jul 14, 2025
fs-eire
reviewed
Jul 14, 2025
fs-eire
reviewed
Jul 16, 2025
fs-eire
reviewed
Jul 16, 2025
fs-eire
reviewed
Jul 16, 2025
Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com>
Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com>
Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com>
fs-eire
approved these changes
Jul 16, 2025
Contributor
|
Hi there! We haven't cut the release branch for this version yet, so I'm removing the |
guschmue
pushed a commit
that referenced
this pull request
Aug 1, 2025
…gth (#25594) ### Description <!-- Describe your changes. --> #25372 adds sliding window support for Group Query Attention, disabling Flash Attention as it's not yet supported. This PR adds a check for the sliding window and applies Flash Attention when the window size exceeds the KV cache length or total sequence length. ### Motivation and Context See above.
snnn
pushed a commit
that referenced
this pull request
Aug 1, 2025
…gth (#25594) ### Description <!-- Describe your changes. --> #25372 adds sliding window support for Group Query Attention, disabling Flash Attention as it's not yet supported. This PR adds a check for the sliding window and applies Flash Attention when the window size exceeds the KV cache length or total sequence length. ### Motivation and Context See above.
qti-yuduo
pushed a commit
to CodeLinaro/onnxruntime
that referenced
this pull request
Aug 8, 2025
Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com>
sanketkaleoss
pushed a commit
to sanketkaleoss/onnxruntime
that referenced
this pull request
Aug 11, 2025
Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com>
sanketkaleoss
pushed a commit
to sanketkaleoss/onnxruntime
that referenced
this pull request
Aug 11, 2025
…gth (microsoft#25594) ### Description <!-- Describe your changes. --> microsoft#25372 adds sliding window support for Group Query Attention, disabling Flash Attention as it's not yet supported. This PR adds a check for the sliding window and applies Flash Attention when the window size exceeds the KV cache length or total sequence length. ### Motivation and Context See above.
gedoensmax
pushed a commit
to gedoensmax/onnxruntime
that referenced
this pull request
Sep 2, 2025
…gth (microsoft#25594) ### Description <!-- Describe your changes. --> microsoft#25372 adds sliding window support for Group Query Attention, disabling Flash Attention as it's not yet supported. This PR adds a check for the sliding window and applies Flash Attention when the window size exceeds the KV cache length or total sequence length. ### Motivation and Context See above.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.